<?php
declare(strict_types=1);

namespace App\Controller;

use App\Model\Tencrypt\Tencrypt;
use Hyperf\DbConnection\Db;
use Hyperf\HttpMessage\Exception\HttpException;

class LoginController extends AbstractController
{
    /***
     * @desc 登录方法
     * */
    public function login()
    {

        throw new HttpException(500,'ceshi Ex');
        /*return "login";
        $userName = $this->request->input('username');
        $passWord = $this->request->input("password");
        //生成加密TOKEN
        return [$userName,$passWord];*/
       // $data = ['wo','shi','yi','ge'];
       // $key = self::randString(32);
       /* $T = new Tencrypt();
        $token  = 'b2ce21e0d87de408b3ea6ab303c0bc4fb19a43e27bbc367024512c38632515794cb9d24ccc8c';
        $token_key = 'uuywkskgsqsy5hfq0ei5q8roawt95vo4';
        $result = $T->Decrypt($token,$token_key);
        return $result;*/
        //$result = $T->Encrypt(json_encode($data),$key);

       // $result = Tencrypt::getInstance()->Encrypt(json_encode($data),$key);

      //  $data = Db::table('user')->get();
        //$data  = Db::select("select * from tml_user");
     //   return ['token'=>$result,'key'=>$key];
    return "123";
    }
    public static function randString($len)
    {
        $chars = '0123456789abcdefghijklmnopqrstuvwxyz'; // characters to build the password from
        $string = "";
        for ($i = $len; $i > 0; $i--) {
            $position = rand() % strlen($chars);
            $string .= substr($chars, $position, 1);
        }
        return $string;
    }
    //注册
}